package cheme.ProcessModel;

import java.io.Serializable;

import org.eclipse.draw2d.geometry.Point;

import cheme.ProcessModel.Visitors.IModelVisitor;

public class TooltipModel extends AbstractChild implements ITranslatable, Serializable, IXmlOperations
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	String message = "";
	protected Point location = null;
	boolean bVisible = false;

	private static TooltipModel instance = null;
	   protected TooltipModel(IModelElement parent) 
	   {
		   super(parent);
	      // Exists only to defeat instantiation.
	   }
	   public static TooltipModel getInstance(IModelElement parent) 
	   {
	      if(instance == null) 
	      {
	         instance = new TooltipModel(parent);
	      }
	      return instance;
	   }
	
	   // to be used after the tooltipmodel object is created.
	   public static TooltipModel getInstance()
	   {
		   return instance;
	   }
	
	@Override
	public Object accept(IModelVisitor visitor) {
		// TODO Auto-generated method stub
		return null;
	}
	
	// function to set the visibility	
	public void setvisibility(boolean bVisible)
	{
		this.bVisible = bVisible;
		firePropertyChange(IPropertyAware.P_VISIBILITY, "", bVisible);	
	}
	
	// function to set the points	
	public void setLocation(Point location)
	{
		if(!this.location.equals(location))
		{
			Point oldBounds = this.location;
			
			this.location = location;
	
			firePropertyChange(P_CONSTRAINT, oldBounds, location);
		}
	}
	
	public Point getLocation()
	{
		if(null == location)
		{
			location = new Point(10,400);
			//location = new Point(420,10);
		}
		
		return location;
	}
	
	// function to set the text
	public void setTipText(String message)
	{
		String oldValue = "";
		this.message = message;
		firePropertyChange(IPropertyAware.P_TEXT, oldValue, message);	
	}
	
	// returns the current message
	public String getMessage()
	{
		return message;
	}
	
	public boolean getVisibility()
	{
		return bVisible;
	}
	public Object fromXml() {
		// TODO Auto-generated method stub
		return null;
	}
	public String toXml() {
		// TODO Auto-generated method stub
		return "";
	}

}
